package com.better.consist;

/**
 * Created by xiaq on 2017/8/22 0022.
 * 考试信息相关枚举
 */
public enum ExamEnum {
    /**
     * 考试科目试卷编辑状态
     */
    PAPER_STATUS_EDIT("编辑",0,1001),
    PAPER_STATUS_FINISH("完成",1,1001),


    /**
     * 考试状态
     */
    EXAM_STATUS_NEW("新增考试",0,1002),     //取消该状态
    EXAM_STATUS_PAPER("编辑试卷",1,1002),
    EXAM_STATUS_SCORE("导入成绩",2,1002),
    EXAM_STATUS_CALTYPE("分析设置",3,1002),
    EXAM_STATUS_PUBLISH("发布成绩",4,1002),
    ;
    private String name;
    private Integer code;
    private Integer teamId;

    ExamEnum(String name, Integer code, Integer teamId) {
        this.name = name;
        this.code = code;
        this.teamId = teamId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getTeamId() {
        return teamId;
    }

    public void setTeamId(Integer teamId) {
        this.teamId = teamId;
    }

    /**
     * 通过code获取name
     * @param index
     * @return
     */
    public static String getName(int index,int team) {
        try {
            for (ExamEnum e : ExamEnum.values()) {
                if (e.getCode() - index==0 && e.getTeamId()==team) {
                    return e.name;
                }
            }
        }catch (Exception e){}
        return null;
    }
    public static String getName(Integer index) {
        try {
            for (ExamEnum e : ExamEnum.values()) {
                if (e.getCode() - index==0) {
                    return e.name;
                }
            }
        }catch (Exception e){}
        return null;
    }

    /**
     * 通过name获取code
     * @param name
     * @return
     */
    public static Integer getCodeByName(String name){
        for (ExamEnum e : ExamEnum.values()) {
            if (name!=null && name.equals(e.getName())) {
                return e.code;
            }
        }
        return null;
    }
}
